package org.rency.crawler.integration.kafka;

import java.time.LocalDateTime;
import javax.annotation.Resource;
import org.junit.Test;
import org.rency.common.utils.domain.BaseResult;
import org.rency.crawler.common.helper.GeneratorHelper;
import org.rency.crawler.domain.queue.FetchQueue;
import org.rency.crawler.integration.BaseTest;
import org.rency.crawler.integration.queue.QueueClient;
import org.springframework.util.Assert;

/**
 * 描述: ${TODO}<br>
 * 最近修改时间:2017/11/29 16:29<br>
 *
 * @author CaiyuRen
 * @version V1.0
 * @since 2017/11/29 16:29
 */
public class KafkaClient extends BaseTest {

  @Resource
  private QueueClient<FetchQueue> fetchQueueClient;

  @Test
  public void testPublish(){
    FetchQueue queue = new FetchQueue();
    queue.setFetchUri("https://www.douban.com");
    queue.setHostAddr("https://www.douban.com");
    queue.setFetchNo(GeneratorHelper.genHashCode(queue.getFetchUri()));
    queue.setFetchHost(GeneratorHelper.genHashCode(queue.getHostAddr()));
    queue.setGmtCreate(LocalDateTime.now());
    BaseResult result = fetchQueueClient.publish(queue);
    logger.info("事件发布结果:{}",result);
    Assert.isTrue(result.isSuccess(),"事件发布失败");
    while (true){

    }
  }
}
